﻿namespace DCHealthCheck.DomainModel {

    #region Usings
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Data.Entity;
    using System.Data.Entity.Infrastructure;
    using System.Data.Entity.Validation;
    using System.Data.Objects; 
    #endregion

    /// <summary>
    /// Interface methods for EntityManager implementation.  
    /// </summary>
    public interface IEntityManager {

        DbContextConfiguration Configuration { get; }
        Exception LastError { get; }
        System.Data.Objects.ObjectContext ObjectContext { get; }
        QuerySets QuerySets { get; }
        List<DbEntityValidationResult> ValidationSummary { get; }

        DbEntityEntry<TEntity> Attach<TEntity>(TEntity entity) where TEntity : class, IObjectWithState;
        void Detach(IObjectWithState entity);
        void Detach(IObjectWithState entity, bool detachChildren);
        DbEntityValidationResult GetValidationResult<TEntity>(TEntity entity) where TEntity : class, IObjectWithState;
        DbSet<TEntity> Set<TEntity>() where TEntity : class;
        int SaveChanges();
        int SaveChanges(bool bulkUpdate);

        #region Compiled Query Launchers
        System.Linq.IQueryable<TReturnType> Query<TReturnType>(Func<DCHealthCheckEntities, System.Linq.IQueryable<TReturnType>> query);
        System.Linq.IQueryable<TReturnType> Query<Arg0, TReturnType>(Func<DCHealthCheckEntities, Arg0, System.Linq.IQueryable<TReturnType>> query, Arg0 arg0);
        System.Linq.IQueryable<TReturnType> Query<Arg0, Arg1, TReturnType>(Func<DCHealthCheckEntities, Arg0, Arg1, System.Linq.IQueryable<TReturnType>> query, Arg0 arg0, Arg1 arg1);
        System.Linq.IQueryable<TReturnType> Query<Arg0, Arg1, Arg2, TReturnType>(Func<DCHealthCheckEntities, Arg0, Arg1, Arg2, System.Linq.IQueryable<TReturnType>> query, Arg0 arg0, Arg1 arg1, Arg2 arg2);

        System.Linq.IQueryable<TReturnType> Query<TReturnType>(Func<DCHealthCheckEntities, System.Linq.IQueryable<TReturnType>> query, System.Data.Objects.MergeOption mergeOption);
        System.Linq.IQueryable<TReturnType> Query<Arg0, TReturnType>(Func<DCHealthCheckEntities, Arg0, System.Linq.IQueryable<TReturnType>> query, Arg0 arg0, System.Data.Objects.MergeOption mergeOption);
        System.Linq.IQueryable<TReturnType> Query<Arg0, Arg1, TReturnType>(Func<DCHealthCheckEntities, Arg0, Arg1, System.Linq.IQueryable<TReturnType>> query, Arg0 arg0, Arg1 arg1, System.Data.Objects.MergeOption mergeOption);
        System.Linq.IQueryable<TReturnType> Query<Arg0, Arg1, Arg2, TReturnType>(Func<DCHealthCheckEntities, Arg0, Arg1, Arg2, System.Linq.IQueryable<TReturnType>> query, Arg0 arg0, Arg1 arg1, Arg2 arg2, System.Data.Objects.MergeOption mergeOption);
        #endregion

        #region Native SQL methods
        DataTable ExecuteSql(System.Data.SqlClient.SqlCommand sqlCommand);
        int ExecuteNonQuerySql(System.Data.SqlClient.SqlCommand sqlCommand);
        object ExecuteScalarSql(System.Data.SqlClient.SqlCommand sqlCommand);

        ObjectResult<TEntity> ExecuteSql<TEntity>(string sql, params object[] parameters) where TEntity : class;
        ObjectResult<TEntity> ExecuteSql<TEntity>(string sql, string entitySetName, System.Data.Objects.MergeOption mergeOption, params object[] parameters) where TEntity : class;
        ObjectResult<TEntity> ExecuteStoredProcedure<TEntity>(string functionName, params System.Data.Objects.ObjectParameter[] parameters) where TEntity : class;
        ObjectResult<TEntity> ExecuteStoredProcedure<TEntity>(string functionName, System.Data.Objects.MergeOption mergeOption, params System.Data.Objects.ObjectParameter[] parameters) where TEntity : class;
        
        #endregion
    }
}
